/**
 * 
 */
package co.edu.udem.service.subject;

import java.util.Arrays;
import java.util.List;

/**
 * @since 17/07/2012
 */
public enum SubjectPeriod {

	DAILY(1, "Diario"), WEEKLY(2, "Semanal"), MONTHLY(3, "Mensual"), SEMIANNUAL(
			4, "Semestral"), ANNUAL(5, "Anual");

	int code;

	String name;

	SubjectPeriod(int code, String name) {
		this.code = code;
		this.name = name;
	}

	public static List<SubjectPeriod> getCodesAsList() {
		return Arrays.asList((new SubjectPeriod[] { SubjectPeriod.DAILY,
				SubjectPeriod.WEEKLY, SubjectPeriod.MONTHLY,
				SubjectPeriod.SEMIANNUAL, SubjectPeriod.ANNUAL }));
	}

	public static String getUserTypeDescriptionByCode(int code) {
		if (code == DAILY.getCode()) {
			return DAILY.getName();
		} else if (code == WEEKLY.getCode()) {
			return WEEKLY.getName();
		} else if (code == MONTHLY.getCode()) {
			return MONTHLY.getName();
		} else if (code == SEMIANNUAL.getCode()) {
			return SEMIANNUAL.getName();
		} else if (code == ANNUAL.getCode()) {
			return ANNUAL.getName();
		}
		return null;
	}

	/**
	 * @return the code
	 */
	public int getCode() {
		return code;
	}

	/**
	 * @param code
	 *            the code to set
	 */
	public void setCode(int code) {
		this.code = code;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

}